home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / tobby_on_ice.swf / scripts / DefineSprite_197_bull / frame_1 / DoAction.as
Text File  |  2011-08-19  |  3KB  |  132 lines

  1. function main()
  2. {
  3.    var _loc1_ = this;
  4.    switch(_loc1_.stat)
  5.    {
  6.       case "walk":
  7.          _loc1_.walk();
  8.          break;
  9.       case "walk2":
  10.          _loc1_.walk2();
  11.          break;
  12.       case "stay2":
  13.          _loc1_.stay2();
  14.    }
  15.    _loc1_.hitCheck();
  16. }
  17. function reSetLoc()
  18. {
  19.    var _loc1_ = this;
  20.    _loc1_.stat = _loc1_.initStatList[_root.stageNum - 1];
  21.    _loc1_.anmStat = "walk";
  22.    _loc1_.anmMC.gotoAndPlay("walk");
  23.    _loc1_.walkDirect = -1;
  24.    _loc1_._xscale = -100;
  25.    _loc1_.worldx = 0;
  26.    _loc1_.baseX = _loc1_.initX;
  27.    _loc1_._y = _loc1_.initY;
  28.    _loc1_.pdx = _loc1_.pdxList[_root.stageNum - 1];
  29. }
  30. function hitCHeck()
  31. {
  32.    var _loc2_ = this;
  33.    if(_loc2_.hitTest(_root.tobbyMC))
  34.    {
  35.       var _loc1_ = _root.tobbyMC.hitBull();
  36.       if(_loc1_)
  37.       {
  38.          _loc2_.stat = "win";
  39.          _loc2_.anmMC.gotoAndPlay("win");
  40.       }
  41.    }
  42. }
  43. function walk()
  44. {
  45.    var _loc1_ = this;
  46.    if(_loc1_.anmStat != "walk")
  47.    {
  48.       _loc1_.anmStat = "walk";
  49.       _loc1_.anmMC.gotoAndPlay("walk");
  50.    }
  51.    _loc1_.worldx += _loc1_.pdx * _loc1_.walkDirect;
  52.    if(_loc1_.worldx > 0)
  53.    {
  54.       _loc1_.worldx = 0;
  55.       _loc1_.walkDirect = -1;
  56.       _loc1_._xscale = -100;
  57.    }
  58.    if(_loc1_.worldx < -950)
  59.    {
  60.       _loc1_.worldx = -950;
  61.       _loc1_.walkDirect = 1;
  62.       _loc1_._xscale = 100;
  63.    }
  64. }
  65. function walk2()
  66. {
  67.    var _loc1_ = this;
  68.    var _loc2_ = _loc1_._x - _root.tobbyMC._x;
  69.    if(Math.abs(_loc2_) < 10)
  70.    {
  71.       _loc1_.stat = "stay2";
  72.       _loc1_.ptr = _loc1_.alg2WaitTime;
  73.       _loc1_.anmStat = "stay";
  74.       _loc1_.anmMC.gotoAndStop("stay");
  75.    }
  76.    else
  77.    {
  78.       if(_loc1_.anmStat != "walk")
  79.       {
  80.          _loc1_.anmStat = "walk";
  81.          _loc1_.anmMC.gotoAndPlay("walk");
  82.       }
  83.       if(_loc2_ > 0)
  84.       {
  85.          _loc1_.walkDirect = -1;
  86.          _loc1_._xscale = -100;
  87.       }
  88.       else
  89.       {
  90.          _loc1_.walkDirect = 1;
  91.          _loc1_._xscale = 100;
  92.       }
  93.       _loc1_.worldx += _loc1_.pdx * _loc1_.walkDirect;
  94.       if(_loc1_.worldx > 0)
  95.       {
  96.          _loc1_.worldx = 0;
  97.          _loc1_.walkDirect = -1;
  98.          _loc1_._xscale = -100;
  99.       }
  100.       if(_loc1_.worldx < -950)
  101.       {
  102.          _loc1_.worldx = -950;
  103.          _loc1_.walkDirect = 1;
  104.          _loc1_._xscale = 100;
  105.       }
  106.    }
  107. }
  108. function stay2()
  109. {
  110.    var _loc1_ = this;
  111.    _loc1_.ptr = _loc1_.ptr - 1;
  112.    if(_loc1_.ptr <= 0)
  113.    {
  114.       _loc1_.stat = "walk2";
  115.    }
  116. }
  117. this.initStatList = ["walk","walk2","walk","walk2","walk2"];
  118. this.stat = this.initStatList[_root.stageNum - 1];
  119. this.alg2WaitTimeList = [20,15,20,30,20];
  120. this.alg2WaitTime = this.alg2WaitTimeList[_root.stageNum - 1];
  121. this.ptr = 0;
  122. this.pdxList = [4,3,5,5,6];
  123. this.pdx = this.pdxList[_root.stageNum - 1];
  124. this.walkDirect = -1;
  125. this._xscale = -100;
  126. this.worldx = 0;
  127. this.initX = this._x;
  128. this.initY = this._y;
  129. this.baseX = this.initX;
  130. this.anmStat = "walk";
  131. this.anmMC.gotoAndPlay("walk");
  132.